<!doctype html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    html,
    body {
      width: 100%;
      height: 100%;
    }
    .container {
      width: 100%;
      height: 100%;
      background: url('./bg.png') no-repeat;
      background-size: cover;
    }
    .box {
      width: 1920px;
      height: 1080px;
      background-color: #bfa;
      position: fixed;
      transform-origin: left top;
      left: 50%;
      top: 50%;
    }
    .top {
      width: 100px;
      height: 100px;
      background-color: green;
      margin-left: 50px;
    }
    .bottom {
      width: 100px;
      height: 100px;
      background-color: red;
      margin: 50px;
    }
  </style>
  <body>
    <div class="container">
      <div class="box">
        <div class="top">那啥是是是啥啥啥</div>
        <div class="bottom">那啥是是是啥啥啥</div>
      </div>
    </div>
  </body>
  <script>
    // 控制数据大屏放大缩小
    const box = document.querySelector('.box');
    box.style.transform = `scale(${getScale()}) translate(-50%, -50%)`;
    // 计算缩放的比例
    function getScale(w = 1920, h = 1080) {
      const ww = window.innerWidth / w;
      const wh = window.innerHeight / h;
      return ww < wh ? ww : wh;
    }
    // 窗口大小变化时触发
    window.onresize = () => {
      box.style.transform = `scale(${getScale()}) translate(-50%, -50%)`;
    };
  </script>
</html>
